<?php
include 'publics.php';



if (!empty($_POST)) {
    $name = $_POST['name'];//网页提交上来的数据
    $pass = $_POST['password'];
    $sql ="select username,userpass,sn from table1 where username = '".$name."'" ;
    $mysql = new Mysql();
    $data = $mysql -> select_one($sql);

//    if (!empty($data)){
//        if($pass == $data['userpass']){
//            if($data['sn'] == 1){
//                $_SESSION['name'] = $name;
//                header('Refresh:0;url=login.php');
//                die();
//            }else{
//                echo '<script type="text/javascript">alert("账号冻结");</script>';
//            }
//        }else{
//            echo '<script type="text/javascript">alert("密码错误");</script>';
//        }
//    }else{
//        echo '<script type="text/javascript">alert("账号不存在");</script>';
//    }
    $sqll = "select * from table1 where username = '".$name."' and userpass = '".$pass."'";
    $dats = $mysql -> select_one($sqll);
    if (!empty($dats)){
        if ($dats['sn'] ==1 || $dats['sn'] ==3){
            $_SESSION = $dats;
            header('Refresh:0;url=message.php');
            die();
        }else{
            echo '<script type="text/javascript">alert("账号被冻结");</script>';
        }
    }else{
        echo '<script type="text/javascript">alert("账号或密码错误");</script>';
    }
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录</title>
    <script src="js/jquery.min.js"></script>
</head>
<style type="text/css">
    .dl{
        position: relative;
    }
    .dj{
        box-shadow: 10px 10px 10px #ccc;
        width: 400px;
        height: 400px;
        position:absolute;
        left: 40%;
        top:25%;
    }
    .dj input{
        margin-top: 40px;
    }
</style>
<body>
<form action="" method="post" class="dj">
    <div class="dl">
        账号：<input type="text" value="" placeholder="请输入账号" class="name" name="name">
        <br>
        密码：<input type="text" value="" placeholder="请输入密码" class="phone" name="password">
        <br>
        <input type="submit"  value="登录" onclick="return cit()" style="margin-left: 20px">
        <br>
        <a href="register.php" style="padding-top: 194px;float: right">点击进入注册界面</a>
    </div>
</form>
<script type="text/javascript">
    function cit(){
        var name = $('.name').val();
        var phone = $('.phone').val();

        if(name == ''){
            alert('请输入账号');
            return false;
        }
        if(phone == ''){
            alert('请输入密码');
            return false;
        }
    }
</script>
</body>
</html>



